package com.mxpio.erp.plm.service.impl;

import com.mxpio.erp.common.plm.entity.ProjectProblem;
import com.mxpio.erp.common.plm.entity.ProjectProblemStatusHistory;
import com.mxpio.erp.common.plm.service.ProjectProblemService;
import com.mxpio.erp.common.plm.service.ProjectProblemStatusHistoryService;
import com.mxpioframework.jpa.JpaUtil;
import com.mxpioframework.system.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

@Service
public class ProjectProblemStatusHistoryServiceImpl extends BaseServiceImpl<ProjectProblemStatusHistory> implements ProjectProblemStatusHistoryService {
    @Override
    @Transactional
    public void saveHistory(ProjectProblem projectProblem ,String statusBefore,String remark) {
        ProjectProblemStatusHistory projectProblemStatusHistory = new ProjectProblemStatusHistory();
        projectProblemStatusHistory.setQuestionCode(projectProblem.getQuestionCode());
        projectProblemStatusHistory.setStatusBefore(statusBefore);
        projectProblemStatusHistory.setStatusAfter(projectProblem.getStatus());
        projectProblemStatusHistory.setChangeTime(new Date());
        projectProblemStatusHistory.setChangeUser(projectProblem.getQuestionLeader());
        projectProblemStatusHistory.setRemark(remark);
        this.save(projectProblemStatusHistory);
    }
}
